import rtconfig
Import('RTT_ROOT')
from building import *

# get current directory
cwd = GetCurrentDir()

# The set of source files associated with this SConscript file.
src = Split("""
CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
""")

src += Glob('STM32F4xx_StdPeriph_Driver/src/*.c')


#add for startup script 
if rtconfig.CROSS_TOOL == 'gcc':
     src = src + ['CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f405xx.S']
elif rtconfig.CROSS_TOOL == 'keil':
     src = src + ['CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f40_41xxx.s']
elif rtconfig.CROSS_TOOL == 'iar':
    src = src + ['CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f40_41xxx.s']

path = [cwd + '/STM32F4xx_StdPeriph_Driver/inc', 
    cwd + '/CMSIS/Device/ST/STM32F4xx/Include',
    cwd + '/CMSIS/Include']

CPPDEFINES  = ['USE_STDPERIPH_DRIVER']
CPPDEFINES += ['STM32F40_41xxx']
CPPDEFINES += ['USE_FULL_ASSERT']
CPPDEFINES += ['HSE_VALUE=8000000']
CPPDEFINES += ['PLL_M=8']

group = DefineGroup('STM32_StdPeriph', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)

Return('group')
